package com.heaven.map.controller;


import com.heaven.map.pojo.vo.ResponseInfo;
import com.heaven.map.service.ITUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Heaven
 * @since 2021-10-03
 */
@RestController
@RequestMapping("/api/v1")
public class TUserController {
    private static final Logger log = LoggerFactory.getLogger(TUserController.class);
    @Autowired
    private ITUserService itUserService;
    @GetMapping("/users/counts")
    public ResponseInfo listUsersCount(){
        return itUserService.listCount();
    }
    @GetMapping("/users")
    public ResponseInfo listUsers(@RequestParam("currentPage") Integer currentPage,
                                  @RequestParam("pageSize") Integer pageSize){
        log.debug("CurrentPage:{},PageSize:{}",currentPage,pageSize);
        return itUserService.listUsers(currentPage,pageSize);
    }
    @PatchMapping("/user/{id}")
    public ResponseInfo modifyDriveState(@PathVariable("id") Integer id){
        return itUserService.ModifyDriveState(id);
    }
    
    @GetMapping("/users/driving")
    public ResponseInfo listDrivingUser(@RequestParam("dangerDriving") Integer dangerDriving){
        return itUserService.listDrivingUser(dangerDriving);
    }
    @DeleteMapping("/user/{id}")
    public ResponseInfo deleteUser(@PathVariable("id") Integer id){
        return itUserService.deleteUser(id);
    }
}

